package com.lycos.ludrien.client;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;

public class ListeMots {
	
	private static ArrayList<String> stopList;
	

	private class Mot{
		public int Id;
		public double Idf;
		
		public Mot(int p_id, double p_idf){
			this.Id = p_id;
			this.Idf = p_idf;
		}
	}
	
	private HashMap<String, Mot> listeMots;
	
	public ListeMots(Connection con){
		
		listeMots = new HashMap<String, Mot>();
		listeMots.clear();

		try {

			String req = "Select * from motcle";
			PreparedStatement pstmt = con.prepareStatement(req);
			ResultSet rs = pstmt.executeQuery();

			
			while (rs.next()){
				Mot m = new Mot(rs.getInt(1), rs.getDouble(3));				
				listeMots.put(rs.getString(2), m );
			}


		}catch (Exception e){}
	}
	
	public int getID(String mot){
		int id = 0;
		
		if (listeMots.containsKey(mot)) id = listeMots.get(mot).Id;
		return id;
		
	}
	
	public double getIDF(String mot){
		double idf = 0;
		
		if (listeMots.containsKey(mot)) idf = listeMots.get(mot).Idf;
		return idf;
		
	}
	
}
